<template>
	<view style="touch-action: none;" v-show="!isSortType">
		<!-- #ifdef H5 || APP-PLUS -->
		<view class="customerService" :style="'top:'+topConfig" @touchmove.stop.prevent="setTouchMove">
			<view class="pictrue" @click="goCustomer">
				<image :src="logoConfig"></image>
			</view>
		</view>
		<!-- #endif -->
		<!-- #ifdef MP -->
<!-- 		<view class="customerService" :style="'top:'+topConfig" @touchmove.stop.prevent="setTouchMove"
			v-if="routineContact === '0'">
			<view class="pictrue" @click="goCustomer">
				<image :src="logoConfig"></image>
			</view>
		</view> -->
		<!-- 购物车 -->
		<button class="customerService-sty" :style="'top:'+topConfig" @touchmove.stop.prevent="setTouchMove"
			 @click="toCar">
			<image class="pictrue" :src="logoConfig"></image>
		</button>
		<!-- 打电话 -->
		<button class="customerService-sty" :style="'top:'+topConfig" @touchmove.stop.prevent="setTouchMove"
			v-if="costumIndex==1" @click="makePhone">
			<image class="pictrue" :src="logoConfig"></image>
		</button>
		<!-- 跳转企业微信客服 -->
		<!-- <button class="customerService-sty" :style="'top:'+topConfig" @touchmove.stop.prevent="setTouchMove"
			 @click="wxService">
			<image class="pictrue" :src="logoConfig"></image>
		</button> -->
		<!-- 跳转微信客服 -->
		<button class="customerService-sty" :style="'top:'+topConfig" @touchmove.stop.prevent="setTouchMove"
			open-type="contact">
			<image class="pictrue" :src="logoConfig"></image>
		</button>
		<!-- #endif -->
	</view>
</template>

<script>
	import {
		getCustomer
	} from '@/utils/index.js'
	export default {
		name: 'customerService',
		props: {
			costumIndex:{
				type: String | Number,
				default: 0
			},
			dataConfig: {
				type: Object,
				default: () => {}
			},
			isSortType: {
				type: String | Number,
				default: 0
			},
			phone:{
				type: String,
				default: ''
			}
		},
		data() {
			return {
				routineContact: this.dataConfig.routine_contact_type,
				logoConfig: this.dataConfig.logoConfig.url,
				topConfig: this.dataConfig.topConfig.val ? this.dataConfig.topConfig.val + '%' : '30%'
			};
		},
		created() {
		},
		methods: {
			wxService() {
				uni.openCustomerServiceChat({
					extInfo: {
						url: 'https://work.weixin.qq.com/kfid/kfc6a58d64ae222f4a2'
					},
					corpId: 'wwefb265b5ab9e6efc',
					success(res) {},
					fail(err) {
						uni.showToast({
							title: err.errMsg,
							icon: 'none',
							duration: 2000
						});
					}
				})
				
			},
			makePhone() {
				uni.makePhoneCall({
					phoneNumber: this.phone //仅为示例
				});
			},
			setTouchMove(e) {
				return
				var that = this;
				if (e.touches[0].clientY < 545 && e.touches[0].clientY > 66) {
					that.topConfig = e.touches[0].clientY + 'px'
				}
			},
			goCustomer() {
				console.log(1);
				getCustomer(`/pages/extension/customer_list/chat?productId=${this.ids}`)
			},
			toCar() {
				uni.switchTab({
					url: '/pages/order_addcart/order_addcart'
				})
			}
		}
	}
</script>

<style lang="scss">
	.customerService,
	.customerService-sty {
		position: fixed;
		right: 20rpx;
		z-index: 40;

		.pictrue {
			width: 86rpx;
			height: 86rpx;

			border-radius: 50%;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.customerService-sty {
		background-color: rgba(0, 0, 0, 0) !important;
	}
</style>
